home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93c.txt / 000120_icon-group-sender _Wed Dec 15 20:16:46 1993.msg < prev    next >
Internet Message Format  |  1994-02-02  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Wed, 15 Dec 1993 18:27:05 MST
  2. Date: 15 Dec 93 20:16:46 GMT
  3. From: agate!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!fnnews.fnal.gov!fnalv.fnal.gov!mglass@ucbvax.Berkeley.EDU
  4. Organization: Fermi National Accelerator Lab
  5. Subject: Problem for icon mavens
  6. Message-Id: <1993Dec15.141646.1@fnalo.fnal.gov>
  7. Sender: icon-group-request@cs.arizona.edu
  8. To: icon-group@cs.arizona.edu
  9. Status: R
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12.  
  13.      A question for icon mavens.
  14.  
  15.      If you have a list of numbers "L" and a limit "lim", the
  16. the following will produce all numbers from L which are less
  17. than the limit:
  18.  
  19.         suspend lim > !L
  20.  
  21.      If L happens to be sorted, and quite long, you might want
  22. to improve the process so it does not search the entire list.
  23.  
  24.      An easy way is:
  25.  
  26.         every x := !L do {
  27.             if x < lim then
  28.                  suspend x
  29.             else
  30.                  break
  31.         }
  32.  
  33.      However in my application I have found that each iteration is
  34. so slow, and "lim" is often large enough, that the easy way is not
  35. much improved (on average) over the simple "suspend lim > !L."
  36.  
  37.      Where "binary_search(L, lim)" does the obvious, I have actually
  38. obtained better results with:
  39.  
  40.         suspend !L[1+:binary_search(L, lim)]
  41.  
  42.      So, icon mavens:  What is the clever generation expression which
  43. mimics "suspend lim > !L" without actually scanning all of L?
  44.  
  45. -- Michael Glass            |  Recently not spotted on a bumper sticker:
  46.    mglass@fnalv.fnal.gov    |  "I'd rather be grading"
  47.